﻿using System;
using System.IO;
using System.Collections.Generic;

namespace LoggerNamespace
{
    public class LoggerText: ILogger
    {
        private List<string> log;

        public LoggerText()
        {
            log = new List<string>();
        }

        public void AddMessage(string message)
        {
            log.Add(message + "\n");
        }

        public string ShowLog()
        {
            string result = "";
            foreach (string str in log)
            {
                result += str;
            }
            return result;
        }
        public void SaveLog()
        {
            string outLog;
            StreamWriter sw = new StreamWriter("log.txt");
            outLog = ShowLog();
            sw.Write(outLog);
            sw.Close();
        }
        public static implicit operator LoggerHtml(LoggerText logText)
        {
            string temp;
            LoggerHtml logHtml = new LoggerHtml();
            foreach (string str in logText.log)
            {
                temp = str.Remove(str.Length - 1);
                logHtml.AddMessage(temp);
            }
            return logHtml;
        }
    }
}
